﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.ServiceModel;
using System.Text;
using PearTunes.Model;
using PearTunes.WEB.Helpers;
using System.IO;

namespace PearTunes.WEB
{
    // NOTE: You can use the "Rename" command on the "Refactor" menu to change the interface name "IPearTunesService" in both code and config file together.
    
    /// <summary>
    /// Interface for the standard network operations of PearTunes
    /// </summary>
    [ServiceContract]
    public interface IPearTunesService
    {
        /// <summary>
        /// Gets the collection of albums
        /// </summary>
        /// <returns>Collection of albums</returns>
        [OperationContract]
        [ReferencePreservingDataContractFormat]
        ICollection<Album> GetAlbums();
        /// <summary>
        /// Search for an album by album title
        /// </summary>
        /// <param name="albumtitle">Album title to search for</param>
        /// <returns>The first album match</returns>
        [OperationContract]
        [ReferencePreservingDataContractFormat]
        ICollection<Album> SearchAlbum(string albumtitle);
        /// <summary>
        /// Gets the collection of tracks
        /// </summary>
        /// <returns>Collection of tracks</returns>
        [OperationContract]
        [ReferencePreservingDataContractFormat]
        ICollection<Track> GetTracks();

       
        /// <summary>
        /// Search for a track by track title
        /// </summary>
        /// <param name="tracktitle">Track title to search for</param>
        /// <returns>Collection of matching tracks</returns>
        [OperationContract]
        [ReferencePreservingDataContractFormat]
        ICollection<Track> SearchTrack(string tracktitle);
        /// <summary>
        /// Gets the info of an user by user name
        /// </summary>
        /// <param name="username">User name</param>
        /// <returns>User object with matching user name</returns>
        [OperationContract]
        [ReferencePreservingDataContractFormat]
        User GetUserInfo(string username);
        /// <summary>
        /// Gets a user's bought tracks list
        /// </summary>
        /// <param name="username">User name</param>
        /// <returns>The collection of track that the user has bought</returns>
        [OperationContract]
        [ReferencePreservingDataContractFormat]
        ICollection<Track> GetUserTracks(string username);
        /// <summary>
        /// Gets a file stream by path
        /// </summary>
        /// <param name="path">Path of the file to stream</param>
        /// <returns>The stream of the given track</returns>
        [OperationContract]
        Stream GetFileStream(string path);
        /// <summary>
        /// The user buyes a track
        /// </summary>
        /// <param name="username">The user's name who has bought the track</param>
        /// <param name="t">The track entity that has been bought</param>
        [OperationContract]
        void BuyTrack(string username, Track t);

        /// <summary>
        /// Valides the user by user name and password
        /// </summary>
        /// <param name="username">User name</param>
        /// <param name="pass">Password of the user</param>
        /// <returns>True if the username and password matches, false in other cases</returns>
        [OperationContract]
        bool ValidateUser(string username, string pass);

    }
}
